
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 09/08/2012 21:41:22
-- Generated from EDMX file: F:\losezhang\TestHttpModules\Orchard.Entity\Model1.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [EEE114];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------


-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Common_Area]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Common_Area];
GO
IF OBJECT_ID(N'[dbo].[Common_BaseProp]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Common_BaseProp];
GO
IF OBJECT_ID(N'[dbo].[Common_BasePropValue]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Common_BasePropValue];
GO
IF OBJECT_ID(N'[dbo].[Common_Category]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Common_Category];
GO
IF OBJECT_ID(N'[dbo].[Common_Category_ItemExtendField]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Common_Category_ItemExtendField];
GO
IF OBJECT_ID(N'[dbo].[Common_CategoryProp_R]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Common_CategoryProp_R];
GO
IF OBJECT_ID(N'[dbo].[Common_Grade]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Common_Grade];
GO
IF OBJECT_ID(N'[dbo].[Common_GradeCategory_R]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Common_GradeCategory_R];
GO
IF OBJECT_ID(N'[dbo].[Common_Platform]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Common_Platform];
GO
IF OBJECT_ID(N'[dbo].[Common_Prop_R]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Common_Prop_R];
GO
IF OBJECT_ID(N'[dbo].[Res_AgentItems]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_AgentItems];
GO
IF OBJECT_ID(N'[dbo].[Res_AgentPrice]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_AgentPrice];
GO
IF OBJECT_ID(N'[dbo].[Res_ExtendField]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_ExtendField];
GO
IF OBJECT_ID(N'[dbo].[Res_Free_Resource]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_Free_Resource];
GO
IF OBJECT_ID(N'[dbo].[Res_Import_Resource]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_Import_Resource];
GO
IF OBJECT_ID(N'[dbo].[Res_Import_ResourceProperty]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_Import_ResourceProperty];
GO
IF OBJECT_ID(N'[dbo].[Res_Item]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_Item];
GO
IF OBJECT_ID(N'[dbo].[Res_Item_ExtendFiled]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_Item_ExtendFiled];
GO
IF OBJECT_ID(N'[dbo].[Res_Item_ProvedRecord]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_Item_ProvedRecord];
GO
IF OBJECT_ID(N'[dbo].[Res_Item_Resource_R]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_Item_Resource_R];
GO
IF OBJECT_ID(N'[dbo].[Res_ItemCategory]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_ItemCategory];
GO
IF OBJECT_ID(N'[dbo].[Res_ItemPrice]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_ItemPrice];
GO
IF OBJECT_ID(N'[dbo].[Res_Package_Item]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_Package_Item];
GO
IF OBJECT_ID(N'[dbo].[Res_Resource]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_Resource];
GO
IF OBJECT_ID(N'[dbo].[Res_Resource_ExtendField]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_Resource_ExtendField];
GO
IF OBJECT_ID(N'[dbo].[Res_Resource_ExtendType]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_Resource_ExtendType];
GO
IF OBJECT_ID(N'[dbo].[Res_ResourceProperty]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Res_ResourceProperty];
GO
IF OBJECT_ID(N'[dbo].[Web_ExceptionLog]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Web_ExceptionLog];
GO
IF OBJECT_ID(N'[dbo].[Web_Logs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Web_Logs];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Common_Area'
CREATE TABLE [dbo].[Common_Area] (
    [CodeID] int  NOT NULL,
    [ParentID] int  NOT NULL,
    [Name] varchar(100)  NOT NULL,
    [Status] int  NOT NULL
);
GO

-- Creating table 'Common_BaseProp'
CREATE TABLE [dbo].[Common_BaseProp] (
    [PID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(20)  NOT NULL,
    [IsGradeProp] bit  NULL,
    [DisplayPosition] tinyint  NOT NULL,
    [SortNumber] int  NOT NULL,
    [Status] int  NOT NULL
);
GO

-- Creating table 'Common_BasePropValue'
CREATE TABLE [dbo].[Common_BasePropValue] (
    [VID] int IDENTITY(1,1) NOT NULL,
    [PID] int  NOT NULL,
    [Name] nvarchar(500)  NOT NULL,
    [SortNumber] int  NOT NULL,
    [Status] int  NOT NULL
);
GO

-- Creating table 'Common_Category'
CREATE TABLE [dbo].[Common_Category] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [ParentID] int  NOT NULL,
    [IsBottom] bit  NOT NULL,
    [Name] nvarchar(20)  NOT NULL,
    [GradeAssociation] bit  NULL,
    [XmlAttribute] nvarchar(2000)  NULL,
    [XmlSearchAttribute] nvarchar(2000)  NULL,
    [SortOrder] int  NOT NULL,
    [Status] int  NOT NULL,
    [Icon] varchar(200)  NULL,
    [Level] int  NULL,
    [PlatformID] int  NULL
);
GO

-- Creating table 'Common_Category_ItemExtendField'
CREATE TABLE [dbo].[Common_Category_ItemExtendField] (
    [CategoryID] int  NOT NULL,
    [ExtendFieldID] int  NOT NULL,
    [SortNumber] int  NOT NULL
);
GO

-- Creating table 'Common_CategoryProp_R'
CREATE TABLE [dbo].[Common_CategoryProp_R] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [CID] int  NOT NULL,
    [PID] int  NOT NULL,
    [PNameAlias] nvarchar(20)  NULL,
    [SortOrder] int  NULL
);
GO

-- Creating table 'Common_Grade'
CREATE TABLE [dbo].[Common_Grade] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(50)  NOT NULL
);
GO

-- Creating table 'Common_GradeCategory_R'
CREATE TABLE [dbo].[Common_GradeCategory_R] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [ParentCID] int  NOT NULL,
    [GID] int  NOT NULL,
    [CID] int  NOT NULL,
    [SortOrder] int  NULL
);
GO

-- Creating table 'Common_Platform'
CREATE TABLE [dbo].[Common_Platform] (
    [PlatformID] int  NOT NULL,
    [PlatformName] varchar(100)  NOT NULL,
    [CreateDate] datetime  NOT NULL,
    [UpdateDate] datetime  NOT NULL,
    [Status] int  NOT NULL,
    [APPID] varchar(100)  NOT NULL,
    [APPKey] varchar(100)  NOT NULL,
    [IP] varchar(200)  NOT NULL,
    [BeginDate] datetime  NOT NULL,
    [EndDate] datetime  NOT NULL,
    [description] nvarchar(max)  NULL,
    [ContanctPerson] nvarchar(50)  NULL,
    [Phone] varchar(50)  NULL,
    [email] varchar(50)  NULL
);
GO

-- Creating table 'Common_Prop_R'
CREATE TABLE [dbo].[Common_Prop_R] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [VID1] int  NULL,
    [VID2] int  NULL,
    [TypeID] int  NULL,
    [ResType] int  NULL
);
GO

-- Creating table 'Res_AgentItems'
CREATE TABLE [dbo].[Res_AgentItems] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [UserID] int  NOT NULL,
    [ItemID] int  NOT NULL,
    [ItemType] int  NOT NULL,
    [Status] int  NOT NULL,
    [Info] nvarchar(max)  NULL,
    [BeginTime] datetime  NULL,
    [EndTime] datetime  NOT NULL,
    [LastModifyTime] datetime  NULL,
    [SortOrder] int  NOT NULL,
    [ItemName] nvarchar(250)  NULL
);
GO

-- Creating table 'Res_AgentPrice'
CREATE TABLE [dbo].[Res_AgentPrice] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [ItemID] int  NOT NULL,
    [ItemName] nvarchar(250)  NOT NULL,
    [AgentID] int  NOT NULL,
    [PriceID] int  NOT NULL,
    [Type] nvarchar(1)  NOT NULL,
    [Interval] int  NOT NULL,
    [Price] decimal(9,2)  NOT NULL,
    [Status] int  NOT NULL,
    [AddTime] datetime  NOT NULL
);
GO

-- Creating table 'Res_ExtendField'
CREATE TABLE [dbo].[Res_ExtendField] (
    [ExtendFieldID] int IDENTITY(1,1) NOT NULL,
    [ExtendName] nvarchar(100)  NOT NULL,
    [CreateDate] datetime  NOT NULL,
    [UpdateDate] datetime  NOT NULL,
    [Status] int  NOT NULL
);
GO

-- Creating table 'Res_Free_Resource'
CREATE TABLE [dbo].[Res_Free_Resource] (
    [ResourceID] int  NOT NULL,
    [GradeID] int  NOT NULL,
    [SubjectID] int  NOT NULL,
    [FilePath] nvarchar(256)  NOT NULL,
    [FileTitle] nvarchar(250)  NULL,
    [CreateDate] datetime  NOT NULL,
    [UpdateDate] datetime  NOT NULL,
    [Status] int  NOT NULL,
    [SortNumber] int  NOT NULL,
    [ThumbPath] nvarchar(256)  NULL,
    [CategoryName] varchar(50)  NULL,
    [Import_Verson] varchar(36)  NOT NULL,
    [GradeName] varchar(50)  NULL,
    [SubjectName] varchar(50)  NULL,
    [TeacherName] nvarchar(50)  NULL,
    [ClassFeather] nvarchar(max)  NULL,
    [LikeReason] nvarchar(max)  NULL,
    [ItemID] int  NULL
);
GO

-- Creating table 'Res_Import_Resource'
CREATE TABLE [dbo].[Res_Import_Resource] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [FileTitle] nvarchar(250)  NULL,
    [FileType] nvarchar(50)  NULL,
    [IsFree] bit  NULL,
    [Uploader] int  NULL,
    [FileSize] int  NULL,
    [OriginalPath] nvarchar(256)  NULL,
    [FilePath] nvarchar(256)  NULL,
    [ThumbPath] nvarchar(256)  NULL,
    [Length] int  NULL,
    [Usetimes] int  NULL,
    [Learntimes] int  NULL,
    [Teacher] nvarchar(50)  NULL,
    [ResourceType] int  NULL,
    [Status] int  NULL,
    [Comefrom] int  NULL,
    [MarketPrice] decimal(9,2)  NULL,
    [PriceInfo] nvarchar(255)  NULL,
    [SourceCode] nvarchar(50)  NULL,
    [Info] nvarchar(4000)  NULL,
    [CategoryID] int  NULL,
    [CreateDate] datetime  NOT NULL,
    [Import_Verson] varchar(36)  NOT NULL,
    [PlayType] int  NULL,
    [EncryptFilePath] varchar(256)  NULL,
    [EncryptFileSize] int  NULL
);
GO

-- Creating table 'Res_Import_ResourceProperty'
CREATE TABLE [dbo].[Res_Import_ResourceProperty] (
    [id] int IDENTITY(1,1) NOT NULL,
    [RID] int  NULL,
    [VID] int  NULL,
    [Type] nvarchar(50)  NULL
);
GO

-- Creating table 'Res_Item'
CREATE TABLE [dbo].[Res_Item] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(250)  NULL,
    [ClassHour] int  NULL,
    [Info] nvarchar(4000)  NULL,
    [Uploader] int  NULL,
    [ResourceCount] int  NULL,
    [SmallPicture] nvarchar(500)  NULL,
    [Picture] nvarchar(500)  NULL,
    [BigPicture] nvarchar(500)  NULL,
    [Collects] int  NULL,
    [Clicks] int  NULL,
    [Sales] int  NULL,
    [Recommend] int  NULL,
    [Holder] nvarchar(50)  NULL,
    [Packager] nvarchar(50)  NULL,
    [PackageTime] datetime  NULL,
    [Status] int  NULL,
    [FreeRes] nvarchar(200)  NULL,
    [Scores] decimal(9,2)  NULL,
    [ItemType] int  NULL,
    [IsAgentPrice] bit  NULL,
    [PayType] int  NOT NULL,
    [UpdateTime] datetime  NULL,
    [SaleRadix] int  NULL,
    [PlatformID] int  NULL,
    [FileSize] int  NULL,
    [FilePath] varchar(256)  NULL
);
GO

-- Creating table 'Res_Item_ExtendFiled'
CREATE TABLE [dbo].[Res_Item_ExtendFiled] (
    [ItemID] int  NOT NULL,
    [ExtendFieldID] int  NOT NULL,
    [ExtendInfo] nvarchar(max)  NULL,
    [CreateDate] datetime  NOT NULL,
    [UpdateDate] datetime  NOT NULL,
    [Status] int  NOT NULL
);
GO

-- Creating table 'Res_Item_ProvedRecord'
CREATE TABLE [dbo].[Res_Item_ProvedRecord] (
    [ID] varchar(36)  NOT NULL,
    [ItemID] int  NOT NULL,
    [Reason] nvarchar(500)  NULL,
    [Type] int  NOT NULL,
    [CreateDate] datetime  NOT NULL,
    [Operator] varchar(50)  NOT NULL,
    [OperatorID] int  NOT NULL
);
GO

-- Creating table 'Res_Item_Resource_R'
CREATE TABLE [dbo].[Res_Item_Resource_R] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [ResourceID] int  NOT NULL,
    [ItemID] int  NOT NULL,
    [SortOrder] int  NOT NULL,
    [ResourceName] nvarchar(250)  NULL
);
GO

-- Creating table 'Res_ItemCategory'
CREATE TABLE [dbo].[Res_ItemCategory] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [ItemID] int  NOT NULL,
    [CategoryID] int  NOT NULL,
    [ValueID] int  NULL,
    [XMLValue] nvarchar(200)  NULL,
    [PlatformID] int  NULL
);
GO

-- Creating table 'Res_ItemPrice'
CREATE TABLE [dbo].[Res_ItemPrice] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [ItemID] int  NOT NULL,
    [IsAgentPart] tinyint  NOT NULL,
    [Type] nvarchar(1)  NOT NULL,
    [Interval] int  NOT NULL,
    [MinPrice] decimal(9,2)  NOT NULL,
    [MaxPrice] decimal(9,2)  NOT NULL,
    [StartTime] datetime  NOT NULL,
    [EndTime] datetime  NOT NULL,
    [Status] int  NOT NULL,
    [MarketPrice] decimal(9,2)  NOT NULL,
    [PlatformID] int  NULL
);
GO

-- Creating table 'Res_Package_Item'
CREATE TABLE [dbo].[Res_Package_Item] (
    [PackageID] int  NOT NULL,
    [Res_ItemID] int  NOT NULL,
    [Res_ItemName] nvarchar(250)  NULL,
    [SortNumber] int  NOT NULL
);
GO

-- Creating table 'Res_Resource'
CREATE TABLE [dbo].[Res_Resource] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [FileTitle] nvarchar(256)  NULL,
    [FileType] nvarchar(50)  NULL,
    [PlayType] int  NULL,
    [IsFree] bit  NULL,
    [Uploader] int  NULL,
    [FileSize] int  NULL,
    [OriginalPath] nvarchar(256)  NULL,
    [FilePath] nvarchar(256)  NULL,
    [ThumbPath] nvarchar(256)  NULL,
    [Length] int  NULL,
    [Usetimes] int  NULL,
    [Learntimes] int  NULL,
    [Teacher] nvarchar(50)  NULL,
    [ResourceType] int  NULL,
    [Status] int  NULL,
    [Comefrom] int  NULL,
    [MarketPrice] decimal(9,2)  NULL,
    [PriceInfo] nvarchar(256)  NULL,
    [SourceCode] nvarchar(50)  NULL,
    [Info] nvarchar(4000)  NULL,
    [CategoryID] int  NULL,
    [CreateDate] datetime  NOT NULL,
    [UpdateDate] datetime  NOT NULL,
    [EncryptFilePath] varchar(256)  NULL,
    [EncryptFileSize] int  NULL
);
GO

-- Creating table 'Res_Resource_ExtendField'
CREATE TABLE [dbo].[Res_Resource_ExtendField] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [ResourceID] int  NOT NULL,
    [ExtendTypeID] int  NOT NULL,
    [FieldTitle] nvarchar(max)  NULL,
    [FieldValue] nvarchar(max)  NOT NULL,
    [Sort] int  NOT NULL,
    [CreateDate] datetime  NULL,
    [UpdateDate] datetime  NULL,
    [Status] int  NOT NULL
);
GO

-- Creating table 'Res_Resource_ExtendType'
CREATE TABLE [dbo].[Res_Resource_ExtendType] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(50)  NOT NULL,
    [DataType] nvarchar(50)  NOT NULL,
    [Description] nvarchar(100)  NULL,
    [CreateDate] datetime  NULL
);
GO

-- Creating table 'Res_ResourceProperty'
CREATE TABLE [dbo].[Res_ResourceProperty] (
    [id] int IDENTITY(1,1) NOT NULL,
    [RID] int  NULL,
    [VID] int  NULL,
    [Type] nvarchar(50)  NULL
);
GO

-- Creating table 'Web_ExceptionLog'
CREATE TABLE [dbo].[Web_ExceptionLog] (
    [ExceptionID] varchar(36)  NOT NULL,
    [FullInfo] nvarchar(max)  NOT NULL,
    [Senders] varchar(2000)  NOT NULL,
    [HttpMethod] varchar(50)  NOT NULL,
    [OccurTime] datetime  NOT NULL,
    [Level] int  NOT NULL
);
GO

-- Creating table 'Web_Logs'
CREATE TABLE [dbo].[Web_Logs] (
    [LogID] varchar(36)  NOT NULL,
    [FromURL] varchar(200)  NOT NULL,
    [ExeSQL] varchar(1000)  NOT NULL,
    [FromSystem] int  NOT NULL,
    [HttpMethod] varchar(50)  NOT NULL,
    [Info] nvarchar(max)  NULL,
    [OccurTime] datetime  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [CodeID] in table 'Common_Area'
ALTER TABLE [dbo].[Common_Area]
ADD CONSTRAINT [PK_Common_Area]
    PRIMARY KEY CLUSTERED ([CodeID] ASC);
GO

-- Creating primary key on [PID] in table 'Common_BaseProp'
ALTER TABLE [dbo].[Common_BaseProp]
ADD CONSTRAINT [PK_Common_BaseProp]
    PRIMARY KEY CLUSTERED ([PID] ASC);
GO

-- Creating primary key on [VID] in table 'Common_BasePropValue'
ALTER TABLE [dbo].[Common_BasePropValue]
ADD CONSTRAINT [PK_Common_BasePropValue]
    PRIMARY KEY CLUSTERED ([VID] ASC);
GO

-- Creating primary key on [ID] in table 'Common_Category'
ALTER TABLE [dbo].[Common_Category]
ADD CONSTRAINT [PK_Common_Category]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [CategoryID], [ExtendFieldID] in table 'Common_Category_ItemExtendField'
ALTER TABLE [dbo].[Common_Category_ItemExtendField]
ADD CONSTRAINT [PK_Common_Category_ItemExtendField]
    PRIMARY KEY CLUSTERED ([CategoryID], [ExtendFieldID] ASC);
GO

-- Creating primary key on [ID] in table 'Common_CategoryProp_R'
ALTER TABLE [dbo].[Common_CategoryProp_R]
ADD CONSTRAINT [PK_Common_CategoryProp_R]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Common_Grade'
ALTER TABLE [dbo].[Common_Grade]
ADD CONSTRAINT [PK_Common_Grade]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Common_GradeCategory_R'
ALTER TABLE [dbo].[Common_GradeCategory_R]
ADD CONSTRAINT [PK_Common_GradeCategory_R]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [PlatformID] in table 'Common_Platform'
ALTER TABLE [dbo].[Common_Platform]
ADD CONSTRAINT [PK_Common_Platform]
    PRIMARY KEY CLUSTERED ([PlatformID] ASC);
GO

-- Creating primary key on [ID] in table 'Common_Prop_R'
ALTER TABLE [dbo].[Common_Prop_R]
ADD CONSTRAINT [PK_Common_Prop_R]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Res_AgentItems'
ALTER TABLE [dbo].[Res_AgentItems]
ADD CONSTRAINT [PK_Res_AgentItems]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Res_AgentPrice'
ALTER TABLE [dbo].[Res_AgentPrice]
ADD CONSTRAINT [PK_Res_AgentPrice]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ExtendFieldID] in table 'Res_ExtendField'
ALTER TABLE [dbo].[Res_ExtendField]
ADD CONSTRAINT [PK_Res_ExtendField]
    PRIMARY KEY CLUSTERED ([ExtendFieldID] ASC);
GO

-- Creating primary key on [ResourceID], [GradeID], [SubjectID] in table 'Res_Free_Resource'
ALTER TABLE [dbo].[Res_Free_Resource]
ADD CONSTRAINT [PK_Res_Free_Resource]
    PRIMARY KEY CLUSTERED ([ResourceID], [GradeID], [SubjectID] ASC);
GO

-- Creating primary key on [ID] in table 'Res_Import_Resource'
ALTER TABLE [dbo].[Res_Import_Resource]
ADD CONSTRAINT [PK_Res_Import_Resource]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [id] in table 'Res_Import_ResourceProperty'
ALTER TABLE [dbo].[Res_Import_ResourceProperty]
ADD CONSTRAINT [PK_Res_Import_ResourceProperty]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [ID] in table 'Res_Item'
ALTER TABLE [dbo].[Res_Item]
ADD CONSTRAINT [PK_Res_Item]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ItemID], [ExtendFieldID] in table 'Res_Item_ExtendFiled'
ALTER TABLE [dbo].[Res_Item_ExtendFiled]
ADD CONSTRAINT [PK_Res_Item_ExtendFiled]
    PRIMARY KEY CLUSTERED ([ItemID], [ExtendFieldID] ASC);
GO

-- Creating primary key on [ID] in table 'Res_Item_ProvedRecord'
ALTER TABLE [dbo].[Res_Item_ProvedRecord]
ADD CONSTRAINT [PK_Res_Item_ProvedRecord]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Res_Item_Resource_R'
ALTER TABLE [dbo].[Res_Item_Resource_R]
ADD CONSTRAINT [PK_Res_Item_Resource_R]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Res_ItemCategory'
ALTER TABLE [dbo].[Res_ItemCategory]
ADD CONSTRAINT [PK_Res_ItemCategory]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Res_ItemPrice'
ALTER TABLE [dbo].[Res_ItemPrice]
ADD CONSTRAINT [PK_Res_ItemPrice]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [PackageID], [Res_ItemID] in table 'Res_Package_Item'
ALTER TABLE [dbo].[Res_Package_Item]
ADD CONSTRAINT [PK_Res_Package_Item]
    PRIMARY KEY CLUSTERED ([PackageID], [Res_ItemID] ASC);
GO

-- Creating primary key on [ID] in table 'Res_Resource'
ALTER TABLE [dbo].[Res_Resource]
ADD CONSTRAINT [PK_Res_Resource]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Res_Resource_ExtendField'
ALTER TABLE [dbo].[Res_Resource_ExtendField]
ADD CONSTRAINT [PK_Res_Resource_ExtendField]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [ID] in table 'Res_Resource_ExtendType'
ALTER TABLE [dbo].[Res_Resource_ExtendType]
ADD CONSTRAINT [PK_Res_Resource_ExtendType]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [id] in table 'Res_ResourceProperty'
ALTER TABLE [dbo].[Res_ResourceProperty]
ADD CONSTRAINT [PK_Res_ResourceProperty]
    PRIMARY KEY CLUSTERED ([id] ASC);
GO

-- Creating primary key on [ExceptionID] in table 'Web_ExceptionLog'
ALTER TABLE [dbo].[Web_ExceptionLog]
ADD CONSTRAINT [PK_Web_ExceptionLog]
    PRIMARY KEY CLUSTERED ([ExceptionID] ASC);
GO

-- Creating primary key on [LogID] in table 'Web_Logs'
ALTER TABLE [dbo].[Web_Logs]
ADD CONSTRAINT [PK_Web_Logs]
    PRIMARY KEY CLUSTERED ([LogID] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------